package HashSet集合;

import java.util.Objects;

/**
 * @author Administrator
 * @ClassName Person
 * @TIME 星期二 2020/12/29
 */
public class Person {
    private int age;
    private String name;

    public Person() {
        super();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Person person = (Person) o;
        return age == person.age &&
                Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(age, name);
    }

    public Person(String name, int age) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person[age = " + age + ", name = " + name + "]";
    }

}
